package com.ns.scs.hots.controller;

import com.ns.core.utils.sg.ResultOk;
import com.ns.scs.hots.service.IHotsService;
import lombok.RequiredArgsConstructor;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 热搜top相关操作
 *
 * @author lw
 */
@RestController
@RequestMapping("/top")
@RequiredArgsConstructor
@CrossOrigin
public class TopHotsController {

    private final IHotsService hotsService;


    /**
     * 热门数据
     */
    @GetMapping("hots")
    ResultOk getGroupHots() {
        return ResultOk.getSuccessData(hotsService.getGroupHots());
    }

    /**
     * 热门数据
     */
    @GetMapping("trend")
    ResultOk getHotsTrend(Long timestamp, int day) {
        if (ObjectUtils.isEmpty(timestamp)) {
            timestamp = System.currentTimeMillis();
        }
        return ResultOk.getSuccessData(hotsService.getHotsTrend(timestamp, day));
    }
}
